﻿using System.Collections.Generic;
using System.IO;
using SystemModule;

namespace M2Server
{
    public partial class TNormNpc
    {
        private bool ConditionOfCheckAccountIPList(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            TStringList LoadList;
            string sCharName;
            string sCharAccount;
            string sCharIPaddr;
            string sLine;
            string sName = string.Empty;
            string sIPaddr;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                LoadList = new TStringList();
                try
                {
                    sCharName = PlayObject.m_sCharName;
                    sCharAccount = PlayObject.m_sUserID;
                    sCharIPaddr = PlayObject.m_sIPaddr;
                    if (File.Exists(M2Share.g_Config.sEnvirDir + QuestConditionInfo.sParam1))
                    {
                        LoadList.LoadFromFile(M2Share.g_Config.sEnvirDir + QuestConditionInfo.sParam1);
                        if (LoadList.Count > 0)
                        {
                            for (int i = 0; i < LoadList.Count; i++)
                            {
                                sLine = LoadList[i];
                                if (sLine[0] == ';')
                                {
                                    continue;
                                }
                                sIPaddr = HUtil32.GetValidStr3(sLine, ref sName, new string[] { " ", "/", "\09" });
                                sIPaddr = sIPaddr.Trim();
                                if ((sName == sCharAccount) && (sIPaddr == sCharIPaddr))
                                {
                                    result = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        ScriptConditionError(PlayObject, QuestConditionInfo, M2Share.sSC_CHECKACCOUNTIPLIST);
                    }
                }
                finally
                {
                    Dispose(LoadList);
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCheckAccountIPList");
            }
            return result;
        }
        
        private bool ConditionOfCheckBonusPoint(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            int nTotlePoint;
            int nCount = 0;
            char cMethod;
            try
            {
                result = false;
                nTotlePoint = PlayObject.m_BonusAbil.DC + PlayObject.m_BonusAbil.MC + PlayObject.m_BonusAbil.SC + PlayObject.m_BonusAbil.AC + PlayObject.m_BonusAbil.MAC
                    + PlayObject.m_BonusAbil.HP + PlayObject.m_BonusAbil.MP + PlayObject.m_BonusAbil.Hit + PlayObject.m_BonusAbil.Speed + PlayObject.m_BonusAbil.X2;
                nTotlePoint = nTotlePoint + PlayObject.m_nBonusPoint;
                cMethod = QuestConditionInfo.sParam1[0];
                if (!ScriptBase.GetValValue(PlayObject, QuestConditionInfo.sParam2, ref nCount))
                {
                    nCount = QuestConditionInfo.nParam2;
                }
                switch (cMethod)
                {
                    case '=':
                        if (nTotlePoint == nCount)
                        {
                            result = true;
                        }
                        break;
                    case '>':
                        if (nTotlePoint > nCount)
                        {
                            result = true;
                        }
                        break;
                    case '<':
                        if (nTotlePoint < nCount)
                        {
                            result = true;
                        }
                        break;
                    default:
                        if (nTotlePoint >= nCount)
                        {
                            result = true;
                        }
                        break;
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCheckBonusPoint");
            }
            return result;
        }

        private bool ConditionOfCHECKKIMNEEDLE(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            int ICount = 0;
            int iParam = 0;
            int iDura = 0;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                if (QuestConditionInfo.nParam2 > 0)
                {
                    ICount = QuestConditionInfo.nParam2;
                    PlayObject.QuestCheckItem(QuestConditionInfo.sParam1, ref ICount, ref iParam, ref iDura);
                    if (ICount >= QuestConditionInfo.nParam2)
                    {
                        result = true;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCHECKKIMNEEDLE");
            }
            return result;
        }

        private bool ConditionOfCHECKHUMANPULSE(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                if ((QuestConditionInfo.nParam1 >= 0) && (QuestConditionInfo.nParam1 <= 3) && (QuestConditionInfo.nParam2 >= 0) && (QuestConditionInfo.nParam2 <= 5))
                {
                    if (QuestConditionInfo.nParam2 == 0)
                    {
                        result = true;
                    }
                    else
                    {
                        if ((QuestConditionInfo.sParam3).ToLower().CompareTo(("Hero").ToLower()) == 0)
                        {
                            if (PlayObject.m_MyHero != null)
                            {
                                if (((THeroObject)(PlayObject.m_MyHero)).m_HumPulses[QuestConditionInfo.nParam1].Pulse >= QuestConditionInfo.nParam2 - 1)
                                {
                                    result = true;
                                }
                            }
                        }
                        else
                        {
                            if (PlayObject.m_HumPulses[QuestConditionInfo.nParam1].Pulse >= QuestConditionInfo.nParam2 - 1)
                            {
                                result = true;
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCHECKHUMANPULSE");
            }
            return result;
        }

        private bool ConditionOfCHECKOPENPULSELEVEL(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                if ((QuestConditionInfo.sParam3).ToLower().CompareTo(("Hero").ToLower()) == 0)
                {
                    if (PlayObject.m_MyHero != null)
                    {
                        switch (QuestConditionInfo.nParam1)
                        {
                            case 0:
                                switch (QuestConditionInfo.nParam2)
                                {
                                    case 1:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel0)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 2:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel1)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 3:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel2)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 4:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel3)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 5:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel4)
                                        {
                                            result = true;
                                        }
                                        break;
                                }
                                break;
                            case 1:
                                switch (QuestConditionInfo.nParam2)
                                {
                                    case 1:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel5)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 2:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel6)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 3:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel7)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 4:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel8)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 5:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel9)
                                        {
                                            result = true;
                                        }
                                        break;
                                }
                                break;
                            case 2:
                                switch (QuestConditionInfo.nParam2)
                                {
                                    case 1:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel10)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 2:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel11)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 3:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel12)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 4:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel13)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 5:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel14)
                                        {
                                            result = true;
                                        }
                                        break;
                                }
                                break;
                            case 3:
                                switch (QuestConditionInfo.nParam2)
                                {
                                    case 1:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel15)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 2:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel16)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 3:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel17)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 4:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel18)
                                        {
                                            result = true;
                                        }
                                        break;
                                    case 5:
                                        if (((THeroObject)(PlayObject.m_MyHero)).m_NGLevel >= M2Share.g_Config.PulsePointNGLevel19)
                                        {
                                            result = true;
                                        }
                                        break;
                                }
                                break;
                        }
                    }
                }
                else
                {
                    switch (QuestConditionInfo.nParam1)
                    {
                        case 0:
                            switch (QuestConditionInfo.nParam2)
                            {
                                case 1:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel0)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 2:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel1)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 3:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel2)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 4:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel3)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 5:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel4)
                                    {
                                        result = true;
                                    }
                                    break;
                            }
                            break;
                        case 1:
                            switch (QuestConditionInfo.nParam2)
                            {
                                case 1:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel5)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 2:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel6)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 3:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel7)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 4:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel8)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 5:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel9)
                                    {
                                        result = true;
                                    }
                                    break;
                            }
                            break;
                        case 2:
                            switch (QuestConditionInfo.nParam2)
                            {
                                case 1:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel10)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 2:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel11)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 3:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel12)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 4:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel13)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 5:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel14)
                                    {
                                        result = true;
                                    }
                                    break;
                            }
                            break;
                        case 3:
                            switch (QuestConditionInfo.nParam2)
                            {
                                case 1:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel15)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 2:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel16)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 3:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel17)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 4:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel18)
                                    {
                                        result = true;
                                    }
                                    break;
                                case 5:
                                    if (PlayObject.m_NGLevel >= M2Share.g_Config.PulsePointNGLevel19)
                                    {
                                        result = true;
                                    }
                                    break;
                            }
                            break;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCHECKOPENPULSELEVEL");
            }
            return result;
        }

        private bool ConditionOfCHECKPULSELEVEL(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                if ((QuestConditionInfo.nParam1 >= 0 && QuestConditionInfo.nParam1 <= 3) && (QuestConditionInfo.nParam2 >= 1 && QuestConditionInfo.nParam2 <= 5))
                {
                    if (PlayObject.m_HumPulses[QuestConditionInfo.nParam1].Pulse == QuestConditionInfo.nParam2 - 1)
                    {
                        result = true;
                    }
                    else if (PlayObject.m_HumPulses[QuestConditionInfo.nParam1].Pulse >= QuestConditionInfo.nParam2)
                    {
                        PlayObject.SendMsg(this, Grobal2.RM_OPENPULSE_OK, 1, 0, 0, 0, ""); // 错误参数1为 经络已经打通
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCHECKPULSELEVEL");
            }
            return result;
        }

        private bool ConditionOfCheckVar(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            string sType;
            string sVarName = string.Empty;
            string sVarValue = string.Empty;
            int nVarValue;
            string sName = string.Empty;
            string sMethod = string.Empty;
            char cMethod;
            TDynamicVar DynamicVar;
            bool boFoundVar = false;
            IList<TDynamicVar> DynamicVarList;
            try
            {
                if (QuestConditionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return result;
                    }
                }
                result = false;
                sType = QuestConditionInfo.sParam1;
                sVarName = QuestConditionInfo.sParam2;
                sMethod = QuestConditionInfo.sParam3;
                nVarValue = HUtil32.Str_ToInt(GetLineVariableText(PlayObject, QuestConditionInfo.sParam4), 0);
                sVarValue = GetLineVariableText(PlayObject, QuestConditionInfo.sParam4);
                if ((sType == "") || (sVarName == "") || (sMethod == ""))
                {
                    ScriptConditionError(PlayObject, QuestConditionInfo, M2Share.sSC_CHECKVAR);
                    return result;
                }
                cMethod = sMethod[1];
                DynamicVarList = GetDynamicVarList(PlayObject, sType, ref sName);
                if (DynamicVarList == null)
                {
                    ScriptConditionError(PlayObject, QuestConditionInfo, M2Share.sSC_CHECKVAR);
                    return result;
                }
                else
                {
                    if (DynamicVarList.Count > 0)
                    {
                        for (var i = 0; i < DynamicVarList.Count; i++)
                        {
                            DynamicVar = DynamicVarList[i];
                            if (DynamicVar != null)
                            {
                                if ((DynamicVar.sName).ToLower().CompareTo((sVarName).ToLower()) == 0)
                                {
                                    switch (DynamicVar.VarType)
                                    {
                                        case TVarType.vInteger:
                                            switch (cMethod)
                                            {
                                                case '=':
                                                    if (DynamicVar.nInternet == nVarValue)
                                                    {
                                                        result = true;
                                                    }
                                                    break;
                                                case '>':
                                                    if (DynamicVar.nInternet > nVarValue)
                                                    {
                                                        result = true;
                                                    }
                                                    break;
                                                case '<':
                                                    if (DynamicVar.nInternet < nVarValue)
                                                    {
                                                        result = true;
                                                    }
                                                    break;
                                                default:
                                                    if (DynamicVar.nInternet >= nVarValue)
                                                    {
                                                        result = true;
                                                    }
                                                    break;
                                            }
                                            break;
                                        case TVarType.vString:
                                            switch (cMethod)
                                            {
                                                case '=':
                                                    if ((DynamicVar.sString).ToLower().CompareTo((sVarValue).ToLower()) == 0)
                                                    {
                                                        result = true;
                                                    }
                                                    break;
                                            }
                                            break;
                                    }
                                    boFoundVar = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!boFoundVar)
                    {
                        ScriptConditionError(PlayObject, QuestConditionInfo, M2Share.sSC_CHECKVAR);
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ConditionOfCheckVar");
            }
            return result;
        }

        private void ActionOfUnMaster(TPlayObject PlayObject, TQuestActionInfo QuestActionInfo)
        {
            TPlayObject PoseHuman;
            string sMsg;
            try
            {
                if (QuestActionInfo.sParam6 == "88")
                {
                    PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestActionInfo.sParam7));
                    if (PlayObject == null)
                    {
                        return;
                    }
                }
                if (PlayObject.m_sMasterName == "")
                {
                    GotoLable(PlayObject, "@ExeMasterFail", false);
                    return;
                }
                PoseHuman = ((TPlayObject)(PlayObject.GetPoseCreate()));
                if (PoseHuman == null)
                {
                    GotoLable(PlayObject, "@UnMasterCheckDir", false);
                }
                if (PoseHuman != null)
                {
                    if (QuestActionInfo.sParam1 == "")
                    {
                        if (PoseHuman.m_btRaceServer != Grobal2.RC_PLAYOBJECT)
                        {
                            GotoLable(PlayObject, "@UnMasterTypeErr", false);
                            return;
                        }
                        if (PoseHuman.GetPoseCreate() == PlayObject)
                        {
                            if ((PlayObject.m_sMasterName == PoseHuman.m_sCharName))
                            {
                                if (PlayObject.m_boMaster)
                                {
                                    GotoLable(PlayObject, "@UnIsMaster", false);
                                    return;
                                }
                                if (PlayObject.m_sMasterName != PoseHuman.m_sCharName)
                                {
                                    GotoLable(PlayObject, "@UnMasterError", false);
                                    return;
                                }
                                GotoLable(PlayObject, "@StartUnMaster", false);
                                GotoLable(PoseHuman, "@WateUnMaster", false);
                                return;
                            }
                        }
                    }
                }
                if (((QuestActionInfo.sParam1).ToLower().CompareTo(("REQUESTUNMASTER").ToLower()) == 0))// 正常出师
                {
                    if ((QuestActionInfo.sParam2 == ""))  // PoseHuman-师傅 PlayObject-徒弟
                    {
                        if (PoseHuman != null)
                        {
                            PlayObject.m_boStartUnMaster = true;
                            if (PlayObject.m_boStartUnMaster && PoseHuman.m_boStartUnMaster)
                            {
                                sMsg = GameMsgDef.g_sNPCSayUnMasterOKMsg.Replace("%n", this.m_sCharName);
                                sMsg = sMsg.Replace("%s", PlayObject.m_sCharName);
                                sMsg = sMsg.Replace("%d", PoseHuman.m_sCharName);
                                M2Share.UserEngine.SendBroadCastMsg(sMsg, TMsgType.t_Say);
                                PlayObject.m_sMasterName = "";
                                PoseHuman.m_sMasterName = "";
                                PlayObject.m_boStartUnMaster = false;
                                PoseHuman.m_boStartUnMaster = false;
                                PoseHuman.DelMaster(PlayObject.m_sCharName);// 出师
                                if (M2Share.g_FunctionNPC != null)
                                {
                                    M2Share.g_FunctionNPC.GotoLable(PoseHuman, "@UnMasterEnd", false);// 师傅触发
                                    M2Share.g_FunctionNPC.GotoLable(PlayObject, "@UnMasterEnd1", false);// 徒弟触发
                                }
                                PlayObject.RefShowName();
                                PoseHuman.RefShowName();
                                GotoLable(PlayObject, "@UnMasterEnd", false);
                                GotoLable(PoseHuman, "@UnMasterEnd", false);
                            }
                            else
                            {
                                GotoLable(PlayObject, "@WateUnMaster", false);
                                GotoLable(PoseHuman, "@RevUnMaster", false);
                            }
                        }
                        return;
                    }
                    else
                    {
                        if (((QuestActionInfo.sParam2).ToLower().CompareTo(("FORCE").ToLower()) == 0))// 强行出师
                        {
                            sMsg = GameMsgDef.g_sNPCSayForceUnMasterMsg.Replace("%n", this.m_sCharName);
                            sMsg = sMsg.Replace("%s", PlayObject.m_sCharName);
                            sMsg = sMsg.Replace("%d", PlayObject.m_sMasterName);
                            M2Share.UserEngine.SendBroadCastMsg(sMsg, TMsgType.t_Say);
                            if (M2Share.g_FunctionNPC != null)
                            {
                                M2Share.g_FunctionNPC.GotoLable(PlayObject, "@UnMasterEnd1", false);  // 徒弟触发
                            }
                            PoseHuman = M2Share.UserEngine.GetPlayObject(PlayObject.m_sMasterName);
                            if (PoseHuman != null)
                            {
                                PoseHuman.m_sMasterName = "";
                                PoseHuman.DelMaster(PlayObject.m_sCharName);// 出师
                                if (M2Share.g_FunctionNPC != null)
                                {
                                    M2Share.g_FunctionNPC.GotoLable(PoseHuman, "@UnMasterEnd", false);// 师傅触发
                                }
                                PoseHuman.RefShowName();
                            }
                            else
                            {
                                //M2Share.g_UnForceMasterList.__Lock();
                                try
                                {
                                    //M2Share.g_UnForceMasterList.Add(PlayObject.m_sMasterName + " " + PlayObject.m_sCharName);
                                    M2Share.SaveUnForceMasterList();
                                }
                                finally
                                {
                                    //  M2Share.g_UnForceMasterList.UnLock();
                                }
                            }
                            PlayObject.m_sMasterName = "";
                            GotoLable(PlayObject, "@UnMasterEnd", false);
                            PlayObject.RefShowName();
                        }
                        return;
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TNormNpc.ActionOfUnMaster");
            }
        }

        private bool ConditionOfCHECKHEROOPENOPULS(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            if (QuestConditionInfo.sParam6 == "88")
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                if (PlayObject == null)
                {
                    return result;
                }
            }
            result = false;
            if (PlayObject.m_MyHero != null)
            {
                if (((THeroObject)(PlayObject.m_MyHero)).m_boTrainingNG)
                {
                    result = ((THeroObject)(PlayObject.m_MyHero)).m_boisOpenPuls;
                }
            }
            return result;
        }

        private bool ConditionOfCHECKITMECOUNTDURA(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            return false;
        }


        private bool ConditionOfCHECKHEROPULSEXP(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            char c1;
            if (QuestConditionInfo.sParam6 == "88")
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                if (PlayObject == null)
                {
                    return result;
                }
            }
            result = false;
            c1 = QuestConditionInfo.sParam1[0];
            if (PlayObject.m_MyHero != null)
            {
                switch (c1)
                {
                    case '>':
                        result = ((THeroObject)(PlayObject.m_MyHero)).m_nPulseExp > QuestConditionInfo.nParam2;
                        break;
                    case '<':
                        result = ((THeroObject)(PlayObject.m_MyHero)).m_nPulseExp < QuestConditionInfo.nParam2;
                        break;
                    case '=':
                        result = ((THeroObject)(PlayObject.m_MyHero)).m_nPulseExp == QuestConditionInfo.nParam2;
                        break;
                }
            }
            return result;
        }

        // 检查是否评定过副将英雄
        private bool ConditionOfCheckAssessMentHero(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            if (QuestConditionInfo.sParam6 == "88")
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                if (PlayObject == null)
                {
                    return result;
                }
            }
            result = false;
            if (PlayObject.m_sDeputyHeroCharName != "")
            {
                result = true;
            }
            return result;
        }

        // 评定当前在线英雄是否是副将英雄
        private bool ConditionOfCheckDeputyHero(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            result = false;
            if (PlayObject.m_MyHero != null)
            {
                if (((THeroObject)(PlayObject.m_MyHero)).m_btMentHero == 2)
                {
                    result = true;
                }
            }
            return result;
        }

        private bool ConditionOfCheckHeroAutoPractice(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            if (QuestConditionInfo.sParam6 == "88")
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                if (PlayObject == null)
                {
                    return result;
                }
            }
            if (PlayObject.m_boHeroAutoTraining)
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return result;
        }

        // 检查护体神盾是否训练过
        private bool ConditionOfCHECKSKILL75(TPlayObject PlayObject, TQuestConditionInfo QuestConditionInfo)
        {
            bool result = false;
            if (QuestConditionInfo.sParam6 == "88")
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(GetLineVariableText(PlayObject, QuestConditionInfo.sParam7));
                if (PlayObject == null)
                {
                    return result;
                }
            }
            result = false;
            if ((QuestConditionInfo.sParam1).ToLower().CompareTo(("hero").ToLower()) == 0)
            {
                //if (((THeroObject)(PlayObject.m_MyHero)) != null)
                //{
                //    if (((THeroObject)(PlayObject.m_MyHero)).m_Magic75Skill != null)
                //    {
                //        result = true;
                //    }
                //}
            }
            else
            {
                if (this.m_MagicArr[0][MagicConst.SKILL_75] != null)
                {
                    result = true;
                }
            }
            return result;
        }
    }
}
